/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package vamprest;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author sav
 */
@Entity
@Table(name = "vehicle")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Vehicle.findAll", query = "SELECT v FROM Vehicle v"),
    @NamedQuery(name = "Vehicle.findByIdvehicle", query = "SELECT v FROM Vehicle v WHERE v.idvehicle = :idvehicle"),
    @NamedQuery(name = "Vehicle.findAvailable", query = "SELECT v FROM Vehicle v WHERE v.idstatus.available = 1"),
    @NamedQuery(name = "Vehicle.findByYear", query = "SELECT v FROM Vehicle v WHERE v.year = :year")})
public class Vehicle implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "idvehicle")
    private Integer idvehicle;
    @Basic(optional = false)
    @NotNull
    @Lob
    @Size(min = 1, max = 65535)
    @Column(name = "description")
    private String description;
    @Basic(optional = false)
    @NotNull
    @Lob
    @Size(min = 1, max = 65535)
    @Column(name = "model")
    private String model;
    @Basic(optional = false)
    @NotNull
    @Column(name = "year")
    @Temporal(TemporalType.DATE)
    private Date year;
    @Lob
    @Size(max = 65535)
    @Column(name = "imguri")
    private String imguri;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idvehicle")
    private List<Nfcequipment> nfcequipmentCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idvehicle")
    private List<Vehiclestatus> vehiclestatusCollection;
    @JoinColumn(name = "idstatus", referencedColumnName = "idstatus")
    @ManyToOne(optional = false)
    private Status idstatus;
    @JoinColumn(name = "idconstructor", referencedColumnName = "idconstructor")
    @ManyToOne(optional = false)
    private Constructor idconstructor;

    public Vehicle() {
    }

    public Vehicle(Integer idvehicle) {
        this.idvehicle = idvehicle;
    }

    public Vehicle(Integer idvehicle, String description, String model, Date year) {
        this.idvehicle = idvehicle;
        this.description = description;
        this.model = model;
        this.year = year;
    }

    public Integer getIdvehicle() {
        return idvehicle;
    }

    public void setIdvehicle(Integer idvehicle) {
        this.idvehicle = idvehicle;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getModel() {
        return model;
    }

    public void setModel(String model) {
        this.model = model;
    }

    public Date getYear() {
        return year;
    }

    public void setYear(Date year) {
        this.year = year;
    }

    public String getImguri() {
        return imguri;
    }

    public void setImguri(String imguri) {
        this.imguri = imguri;
    }

    @XmlTransient
    public List<Nfcequipment> getNfcequipmentCollection() {
        return nfcequipmentCollection;
    }

    public void setNfcequipmentCollection(List<Nfcequipment> nfcequipmentCollection) {
        this.nfcequipmentCollection = nfcequipmentCollection;
    }

    @XmlTransient
    public List<Vehiclestatus> getVehiclestatusCollection() {
        return vehiclestatusCollection;
    }

    public void setVehiclestatusCollection(List<Vehiclestatus> vehiclestatusCollection) {
        this.vehiclestatusCollection = vehiclestatusCollection;
    }

    public Status getIdstatus() {
        return idstatus;
    }

    public void setIdstatus(Status idstatus) {
        this.idstatus = idstatus;
    }

    public Constructor getIdconstructor() {
        return idconstructor;
    }

    public void setIdconstructor(Constructor idconstructor) {
        this.idconstructor = idconstructor;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idvehicle != null ? idvehicle.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Vehicle)) {
            return false;
        }
        Vehicle other = (Vehicle) object;
        if ((this.idvehicle == null && other.idvehicle != null) || (this.idvehicle != null && !this.idvehicle.equals(other.idvehicle))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "vamprest.Vehicle[ idvehicle=" + idvehicle + " ]";
    }

}
